<template>
  <div class="home-container">
    <div class="header">
      <h1>文件中转站</h1>
      <p>安全、简单、高效的文件共享平台</p>
    </div>
    
    <div class="content">
      <div class="hero-section">
        <div class="hero-text">
          <h2>高效安全地传输您的文件</h2>
          <p>无需注册，即刻开始分享您的文件</p>
          <div class="hero-actions">
            <el-button 
              type="primary" 
              size="large" 
              @click="$router.push('/upload')"
              class="upload-btn"
            >
              开始上传
            </el-button>
          </div>
        </div>
        <div class="hero-image">
          <div class="device-mockup">
            <div class="device-screen">
              <div class="file-icon">
                <el-icon><Document /></el-icon>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <div class="download-section">
        <div class="download-label">已有下载码？</div>
        <div class="download-code-box">
          <el-input
            v-model="downloadCode"
            placeholder="输入下载码获取文件"
            clearable
            @keyup.enter="handleGetFile"
          >
            <template #append>
              <el-button @click="handleGetFile">获取</el-button>
            </template>
          </el-input>
        </div>
      </div>
      
      <div class="features">
        <h3 class="section-title">核心功能</h3>
        <div class="feature-grid">
          <div class="feature-item">
            <div class="feature-icon">
              <el-icon><Upload /></el-icon>
            </div>
            <div class="feature-content">
              <h4>便捷上传</h4>
              <p>支持多种上传方式，单文件、多文件及文件夹上传，最大支持500MB</p>
            </div>
          </div>
          <div class="feature-item">
            <div class="feature-icon">
              <el-icon><Lock /></el-icon>
            </div>
            <div class="feature-content">
              <h4>安全存储</h4>
              <p>文件存储在腾讯云COS，采用SSL加密传输，安全可靠</p>
            </div>
          </div>
          <div class="feature-item">
            <div class="feature-icon">
              <el-icon><Link /></el-icon>
            </div>
            <div class="feature-content">
              <h4>分享无忧</h4>
              <p>生成唯一下载码，一键复制链接，方便分享给任何人</p>
            </div>
          </div>
          <div class="feature-item">
            <div class="feature-icon">
              <el-icon><Timer /></el-icon>
            </div>
            <div class="feature-content">
              <h4>自动过期</h4>
              <p>文件到期后自动删除，确保隐私安全，减少存储空间占用</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <div class="footer">
      <div class="footer-content">
        <p>© {{ new Date().getFullYear() }} 文件中转站 版权所有</p>
        <p class="footer-desc">安全、高效的文件传输解决方案</p>
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import { Upload, Lock, Link, Timer, Document } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'

export default {
  name: 'HomePage',
  components: {
    Upload,
    Lock,
    Link,
    Timer,
    Document
  },
  setup() {
    const downloadCode = ref('')
    const router = useRouter()
    
    const handleGetFile = () => {
      if (!downloadCode.value) {
        ElMessage.warning('请输入下载码')
        return
      }
      
      router.push(`/file/${downloadCode.value}`)
    }
    
    return {
      downloadCode,
      handleGetFile
    }
  }
}
</script>

<style scoped>
.home-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--background-color) 100%);
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(45deg, var(--primary-color), var(--primary-dark));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
  letter-spacing: -0.5px;
}

.header p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  font-weight: 400;
}

.content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

.hero-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2rem 0 4rem;
  gap: 2rem;
}

.hero-text {
  flex: 1;
}

.hero-text h2 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 1rem;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.hero-text p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.hero-actions {
  margin-top: 2rem;
}

.upload-btn {
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  font-weight: 500;
  border-radius: 12px;
  letter-spacing: 0.5px;
}

.hero-image {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.device-mockup {
  width: 300px;
  height: 600px;
  background-color: var(--secondary-color);
  border-radius: 36px;
  position: relative;
  padding: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.device-screen {
  background-color: var(--background-color);
  border-radius: 30px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  background-color: var(--primary-light);
  border-radius: 20px;
  color: var(--primary-dark);
}

.file-icon i {
  font-size: 48px;
}

.download-section {
  margin: 2rem 0;
  padding: 2rem;
  background-color: white;
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.download-label {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--text-color);
}

.download-code-box {
  max-width: 500px;
  margin: 0 auto;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 3rem 0 2rem;
  color: var(--text-color);
  letter-spacing: -0.5px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.feature-item {
  background-color: white;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.feature-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

.feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background-color: var(--primary-light);
  border-radius: 50%;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.feature-icon i {
  font-size: 24px;
}

.feature-content {
  flex: 1;
}

.feature-content h4 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.feature-content p {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.footer {
  padding: 3rem 2rem;
  background-color: var(--secondary-color);
  color: white;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer p {
  margin: 0.5rem 0;
}

.footer-desc {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

/* 响应式调整 */
@media (max-width: 992px) {
  .hero-section {
    flex-direction: column;
    text-align: center;
  }
  
  .hero-text h2 {
    font-size: 2rem;
  }
  
  .hero-image {
    justify-content: center;
    margin-top: 2rem;
  }
  
  .device-mockup {
    width: 240px;
    height: 480px;
    border-radius: 30px;
  }
  
  .device-screen {
    border-radius: 26px;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 30px 15px;
  }
  
  .header h1 {
    font-size: 2rem;
  }
  
  .header p {
    font-size: 1rem;
  }
  
  .hero-text h2 {
    font-size: 1.75rem;
  }
  
  .hero-text p {
    font-size: 1rem;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
  }
  
  .device-mockup {
    width: 200px;
    height: 400px;
  }
  
  .section-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .download-section {
    padding: 1.5rem;
  }
  
  .feature-item {
    padding: 1.5rem;
  }
  
  .device-mockup {
    width: 180px;
    height: 360px;
  }
}
</style> 